package com.ryan.mdp.annotation.parser;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

import javax.jms.Message;

import com.ryan.mdp.annotation.MdpMethod;
import com.ryan.mdp.annotation.MessageProperty;

/**
 * 解析Mdp方法所得到的配置数据类
 */
public class MdpMethodConfig {

    // 该数据类所对应的Method
    private Method source;
    // 同步调用时超时时间
    private long timeout = MdpMethod.DEFAULT_TIMEOUT;
    // MDP请求、同步返回或异步callback时消息优先级
    private int priority = Message.DEFAULT_DELIVERY_MODE;
    // 同步返回、异步callback时消息存活时间
    private long ttl = 0;
    // 方法是同步还是异步调用，方法有返回值时是同步true，否则为异步false
    private boolean sync = true;
    // 异步调用时是否需要callback，true:异步有callback；false: 异步无callback，此参数在sync=false生效
    private boolean callback = false;
    // 同步方法是否cache，此参数在sync=false生效
    private boolean cache = false;
    // cache失效时间，单位秒
    private long cacheTtl = 0;
    // 参数上的Annotation，主要是动态设置Message Property
    private List<List<MessageProperty>> paramAnnotations = new ArrayList<List<MessageProperty>>();
    // 方法上的Annotation，主要是静态设置Message Property，比如Message压缩
    private List<MessageProperty> methodAnnotations = new ArrayList<MessageProperty>();

    public MdpMethodConfig() {
    }

    public MdpMethodConfig(Method source) {
        this.source = source;
    }

    public Method getSource() {
        return source;
    }

    public void setSource(Method source) {
        this.source = source;
    }

    public long getTimeout() {
        return timeout;
    }

    public void setTimeout(long timeout) {
        this.timeout = timeout;
    }

    public int getPriority() {
        return priority;
    }

    public void setPriority(int priority) {
        this.priority = priority;
    }

    public long getTtl() {
        return ttl;
    }

    public void setTtl(long ttl) {
        this.ttl = ttl;
    }

    public boolean isSync() {
        return sync;
    }

    public void setSync(boolean sync) {
        this.sync = sync;
    }

    public boolean isCallback() {
        return callback;
    }

    public void setCallback(boolean callback) {
        this.callback = callback;
    }

    public boolean isCache() {
        return cache;
    }

    public void setCache(boolean cache) {
        this.cache = cache;
    }

    public long getCacheTtl() {
        return cacheTtl;
    }

    public void setCacheTtl(long cacheTtl) {
        this.cacheTtl = cacheTtl;
    }

    public List<List<MessageProperty>> getParamAnnotations() {
        return paramAnnotations;
    }

    public void setParamAnnotations(List<List<MessageProperty>> paramAnnotations) {
        this.paramAnnotations = paramAnnotations;
    }

    public List<MessageProperty> getMethodAnnotations() {
        return methodAnnotations;
    }

    public void setMethodAnnotations(List<MessageProperty> methodAnnotations) {
        this.methodAnnotations = methodAnnotations;
    }
}